﻿ USE [ForumForJustice]
GO
/****** Object:  Table [dbo].[Master_Roles]    Script Date: 10/06/2011 20:42:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Master_Roles](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Title] [varchar](50) NULL,
	[Title_M] [nvarchar](50) NULL,
	[DateCreated] [datetime] NULL,
	[DateModified] [datetime] NULL,
	[CreatedBy] [bigint] NULL,
	[ModifiedBy] [bigint] NULL,
	[IsDeleted] [bit] NULL,
	[IsActive] [bit] NULL,
 CONSTRAINT [PK_Master_Roles] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Master_ForumCategories]    Script Date: 10/06/2011 20:42:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Master_ForumCategories](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Title] [varchar](50) NULL,
	[Title_M] [nvarchar](50) NULL,
	[DateCreated] [datetime] NULL,
	[DateModified] [datetime] NULL,
	[CreatedBy] [bigint] NULL,
	[ModifiedBy] [bigint] NULL,
	[IsDeleted] [bit] NULL,
	[IsActive] [bit] NULL,
	[ParentId] [int] NULL,
 CONSTRAINT [PK_Master_ForumCategories] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Attachments]    Script Date: 10/06/2011 20:42:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Attachments](
	[Id] [bigint] IDENTITY(1,1) NOT NULL,
	[Title] [varchar](50) NULL,
	[Title_M] [nvarchar](50) NULL,
	[Description] [varchar](max) NULL,
	[Description_M] [nvarchar](max) NULL,
	[Attachment] [varbinary](max) NULL,
	[DateCreated] [datetime] NULL,
	[DateModified] [datetime] NULL,
	[CreatedBy] [bigint] NULL,
	[ModifiedBy] [bigint] NULL,
	[IsDeleted] [bit] NULL,
	[IsActive] [bit] NULL,
 CONSTRAINT [PK_Attachments] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Users]    Script Date: 10/06/2011 20:42:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Users](
	[Id] [bigint] IDENTITY(1,1) NOT NULL,
	[FirstName] [varchar](50) NULL,
	[LastName] [nvarchar](50) NULL,
	[EmailId] [varchar](200) NULL,
	[Password] [varchar](20) NULL,
	[RoleId] [int] NULL,
	[DateCreated] [datetime] NULL,
	[DateModified] [datetime] NULL,
	[CreatedBy] [bigint] NULL,
	[ModifiedBy] [bigint] NULL,
	[IsDeleted] [bit] NULL,
	[IsActive] [bit] NULL,
 CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Forums]    Script Date: 10/06/2011 20:42:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Forums](
	[Id] [bigint] IDENTITY(1,1) NOT NULL,
	[Title] [varchar](50) NULL,
	[Title_M] [nvarchar](50) NULL,
	[Body] [nvarchar](max) NULL,
	[AttachmentId] [bigint] NULL,
	[ForumCategoryId] [int] NULL,
	[DateCreated] [datetime] NULL,
	[DateModified] [datetime] NULL,
	[CreatedBy] [bigint] NULL,
	[ModifiedBy] [bigint] NULL,
	[IsDeleted] [bit] NULL,
	[IsActive] [bit] NULL,
	[SourceIPAddress] [varchar](50) NULL,
 CONSTRAINT [PK_Forums] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Mapping_Forums_Attachements]    Script Date: 10/06/2011 20:42:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Mapping_Forums_Attachements](
	[ForumId] [bigint] NULL,
	[AttachmentId] [bigint] NULL
) ON [PRIMARY]
GO
/****** Object:  ForeignKey [FK_Master_ForumCategories_Master_ForumCategories]    Script Date: 10/06/2011 20:42:20 ******/
ALTER TABLE [dbo].[Master_ForumCategories]  WITH CHECK ADD  CONSTRAINT [FK_Master_ForumCategories_Master_ForumCategories] FOREIGN KEY([ParentId])
REFERENCES [dbo].[Master_ForumCategories] ([Id])
GO
ALTER TABLE [dbo].[Master_ForumCategories] CHECK CONSTRAINT [FK_Master_ForumCategories_Master_ForumCategories]
GO
/****** Object:  ForeignKey [FK_Users_Master_Roles]    Script Date: 10/06/2011 20:42:20 ******/
ALTER TABLE [dbo].[Users]  WITH CHECK ADD  CONSTRAINT [FK_Users_Master_Roles] FOREIGN KEY([RoleId])
REFERENCES [dbo].[Master_Roles] ([Id])
GO
ALTER TABLE [dbo].[Users] CHECK CONSTRAINT [FK_Users_Master_Roles]
GO
/****** Object:  ForeignKey [FK_Forums_Master_ForumCategories]    Script Date: 10/06/2011 20:42:20 ******/
ALTER TABLE [dbo].[Forums]  WITH CHECK ADD  CONSTRAINT [FK_Forums_Master_ForumCategories] FOREIGN KEY([ForumCategoryId])
REFERENCES [dbo].[Master_ForumCategories] ([Id])
GO
ALTER TABLE [dbo].[Forums] CHECK CONSTRAINT [FK_Forums_Master_ForumCategories]
GO
/****** Object:  ForeignKey [FK_Mapping_Forums_Attachements_Attachments]    Script Date: 10/06/2011 20:42:20 ******/
ALTER TABLE [dbo].[Mapping_Forums_Attachements]  WITH CHECK ADD  CONSTRAINT [FK_Mapping_Forums_Attachements_Attachments] FOREIGN KEY([AttachmentId])
REFERENCES [dbo].[Attachments] ([Id])
GO
ALTER TABLE [dbo].[Mapping_Forums_Attachements] CHECK CONSTRAINT [FK_Mapping_Forums_Attachements_Attachments]
GO
/****** Object:  ForeignKey [FK_Mapping_Forums_Attachements_Forums]    Script Date: 10/06/2011 20:42:20 ******/
ALTER TABLE [dbo].[Mapping_Forums_Attachements]  WITH CHECK ADD  CONSTRAINT [FK_Mapping_Forums_Attachements_Forums] FOREIGN KEY([ForumId])
REFERENCES [dbo].[Forums] ([Id])
GO
ALTER TABLE [dbo].[Mapping_Forums_Attachements] CHECK CONSTRAINT [FK_Mapping_Forums_Attachements_Forums]
GO
